<?if($this->anio):?>
<script>
<?php $this->placeholder('onReady')->captureStart() ?>
      	$(".changePlan").change(function () {
	        var id= this.id;
            var dato=this.value
	        
            dato=dato.split(',').join('.');
	        $('#'+id).val(dato);
            

	        if(isNaN(dato)){
        		$('#'+id).addClass('ui-state-error');
        		return true;
       		}

       		var aux=id.split('-')

 	        $.post('<?=$this->baseUrl('cuentas-mmr/editar')?>',{id_naturaleza:aux[0],anio:aux[1],mes:aux[2],idZona:aux[3],tipo:aux[4],dato:dato,version:<?=$this->version?>}, function(data){
                 if(data.status=='ok'){
	  				$('#'+id).removeClass('ui-state-error').css('color','green');
	  				$('#total-'+aux[0]).html(data.suma);
                }else{
                    alert(data);
                }
            
          	
      		}); 
 	 	})      
  <?if($this->version==0):?>
       $("a.button_comite").html('<?php echo $this->translate('Comite');?>').button({icons: {primary:'ui-icon-locked'}});
       $("a.button_locked").html('<?php echo $this->translate('Cerrado');?>').button({icons: {primary:'ui-icon-check'}});
	   $("a.button_unlocked").html('<?php echo $this->translate('Abierto');?>').button({icons: {primary:'ui-icon-unlocked'}});
  
  
        <?foreach($this->estados as $mes=>$v):
        if($v['estado']):?>
            $(".mes-<?=$mes?>").attr("disabled",true).toggleClass("ui-priority-secondary")
        <?endif;
        endforeach;?>
        
        
        
        
    $(".button_locked_comite").click(function () {
	        aux=this.id.split('-');
            mes=aux[1];   
            
	
            $.post('<?=$this->baseUrl('cuentas-mmr/lock')?>', {objeto_cambio:0, mes: mes,anio: <?=$this->anio?>,idZona: <?=$this->idZona?>,version:<?=$this->version?>},function(data){
                if(data.status!='ok'){
                     alert(data)
                }else{
                   location.reload();
                }
    		})
	});
         
    $(".button_unlocked").click(function () {

	    aux=this.id.split('-');
        mes=aux[1];   
        notas = prompt('Introduce un comentario');

        if(notas!=null){
             $.post('<?=$this->baseUrl('cuentas-mmr/lock')?>', {objeto_cambio:1,notas:notas, mes: mes,anio: <?=$this->anio?>,idZona: <?=$this->idZona?>,version:<?=$this->version?>},function(data){
                if(data.status!='ok'){
                     alert(data)
                }else{
                   location.reload();
                }    
    		});
        }
        return false;
	});    
    
    <?endif?>
        
        
        
        

  
<?php $this->placeholder('onReady')->captureEnd() ?>

</script>


<div class="contenedor_tablesorter">

<table class="tabla_cuentas_registro" > 
<caption>

<h1 class="h1_head ui-widget-header" style="">
<?=$this->translate('Registro Avance Servicio Comunicaciones , Implantaciones e Instalaciones').' '.$this->anio .' '.$this->zona?>
</h1>

</caption>
<thead>
    <tr class="ui-state-hover">
        <th></th>
        <?foreach($this->meses as $v):?>
            <th><?=$v?></th>
        <?endforeach?>
        <th><?php echo $this->translate('Anual');?></th>
    </tr>


<tr class="ui-state-highlight">
    <th><?php echo $this->translate('Mes Abierto / Cerrado');?></th>
    <?for($i=1;$i<13;$i++):
    if($this->estados[$i]['estado']==1):?>   
    <td><a class="button_locked button_locked_comite" id="m-<?=$i?>" title="<?=$this->estados[$i]['notas_cambio']?>">&nbsp;</a></td> 
    <?elseif($this->estados[$i]['objeto_cambio']==1):?>
    <td><a class="button_comite button_locked_comite"  id="m-<?=$i?>"></a></td> 
    <?else:?>
    <td><a class="button_unlocked"  id="m-<?=$i?>"></a></td> 
    <?endif; 
    endfor?>
	<td></td>   
</tr>



</thead>
<tbody>
<?php echo $this->sap_coste;?>
<?php echo $this->sap_inversa;?>
<tr class="ui-state-hover"><td colspan="14">&nbsp;</td></tr>
<?php echo $this->contratas_electricidad;?>
<?php echo $this->contratas_mmr;?>
<?php echo $this->mano_obra_electricidad;?>
<?php echo $this->mano_obra_mmr;?>
<?php echo $this->renting;?>
<?php echo $this->coste;?>
<tr class="ui-state-hover"><td colspan="14">&nbsp;</td></tr>
<?php echo $this->inversa_electricidad;?>
<?php echo $this->inversa_mmr;?>
<tr class="ui-state-hover"><td colspan="14">&nbsp;</td></tr>
<?php echo $this->inmovilizado_manoobra;?>
<?php echo $this->inmovilizado_materiales;?>

</tbody>
</table>
</div>

<div style="clear:both"></div>
    
<?endif;//anio	?>	
    	